<!DOCTYPE html>
<html>
  <head>
    <title>trigger.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	<script type="text/javascript" src="../javascript/lib/jquery-1.9.1/jquery-1.9.1.min.js"></script>
	<style type="text/css">
		div{
			padding: 10 10 10 10;
			width: 100px;
			height: 100px;
		}
		.div1{
			background-color: green;
		}
		.div2{
			background-color: yellow;
		}
		.div3{
			background-color: blue;
		}
	</style>
	<script type="text/javascript">
		$(function(){
			$("p").hide();
			
			$(".div1", this).mouseover(function(){
				$(this).find("p").fadeIn().fadeOut();
			});
			$(".div2", this).mouseover(function(){
				$(this).find("p").fadeIn().fadeOut();
			});
			$(".div3", this).mouseover(function(){
				$(this).find("p").fadeIn().fadeOut();
			});
			//trigger：整个匹配集合中每个元素的事件处理程序，且向上冒泡。
			$($("input")[0]).click(function(){
				$("div").trigger("mouseover");
			});
			//triggerHandler：只执行第一个匹配对象的事件处理程序，且不向上冒泡。
			$($("input")[1]).click(function(){
				$("div").triggerHandler("mouseover");
			});
			
		})
	</script>
  </head>
  
  <body>
    <div class="div1">
    	<p>here</p>
    </div>
    <div class="div2">
    	<p>here</p>
    </div>
    <div class="div3">
    	<p>here</p>
    </div>
    <input type="button" value="run with trigger" />
    <input type="button" value="run with triggerHandler" />
  </body>
</html>
